﻿package mortal.game.view.common.tooltip.tooltips.equipment
{
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import extend.language.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.display.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class ToolTipStoneItem extends GSprite
    {
        private var _bg:GBitmap;
        private var _icon:GBitmap;
        private var _txtName:GTextFiled;
        private var _txtStatus:GTextFiled;
        private var _txtLevel:GTextFiled;

        public function ToolTipStoneItem()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gBitmap(ImagesConst.StoneBg, 0, 0, this);
            this._icon = UIFactory.gBitmap(null, 2, 2, this);
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.leading = 2;
            this._txtName = UIFactory.gTextField("", 32, -2, 95, 40, this, GlobalStyle.textFormatPutong.setLeading(-3));
            this._txtName.multiline = true;
            this._txtName.wordWrap = true;
            this._txtStatus = UIFactory.gTextField("", 33, 4, 130, 20, this);
            this._txtStatus.filters = [FilterConst.colorFilter];
            _loc_1 = GlobalStyle.textFormatHuang2;
            _loc_1.size = 10;
            _loc_1.align = TextFormatAlign.RIGHT;
            this._txtLevel = UIFactory.gTextField("", -5, 11, 34, 20, this, _loc_1);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._icon.dispose(param1);
            this._txtName.dispose(param1);
            this._txtStatus.dispose(param1);
            this._txtLevel.dispose();
            this._bg = null;
            this._icon = null;
            this._txtName = null;
            this._txtStatus = null;
            this._txtLevel = null;
            return;
        }// end function

        public function set stoneData(param1:ToolTipStoneData) : void
        {
            var _loc_2:String = null;
            var _loc_3:String = null;
            var _loc_4:String = null;
            if (param1.isLocked)
            {
                DisplayUtil.removeMe(this._txtName);
                DisplayUtil.removeMe(this._txtLevel);
                this.addChild(this._txtStatus);
                this._txtStatus.text = param1.openTips;
                this._icon.bitmapData = GlobalClass.getBitmapData(ImagesConst.Locked);
                this._icon.width = 25;
                this._icon.height = 25;
            }
            else if (param1.itemData == null)
            {
                DisplayUtil.removeMe(this._txtName);
                DisplayUtil.removeMe(this._txtLevel);
                this.addChild(this._txtStatus);
                this._txtStatus.text = Language.getString(20203);
                this._icon.bitmapData = GlobalClass.getBitmapData(BitmapDataConst.AlphaBMD);
            }
            else if (param1.itemData != null)
            {
                this.addChild(this._txtName);
                DisplayUtil.removeMe(this._txtStatus);
                if (this._txtLevel.parent == null)
                {
                    this.addChild(this._txtLevel);
                }
                this._txtLevel.text = param1.itemData.itemInfo.itemLevel.toString();
                _loc_2 = GameDefConfig.instance.getItem("FightRoleAttribute", param1.itemData.itemInfo.type).text1;
                _loc_3 = param1.itemData.itemInfo.name + "<br/>" + _loc_2 + "+" + param1.itemData.itemInfo.effectEx;
                _loc_4 = ColorConfig.instance.getItemColorString(param1.itemData.itemInfo.color);
                this._txtName.htmlText = HTMLUtil.addColor(_loc_3, _loc_4);
                LoaderManager.instance.load(param1.itemData.itemInfo.icon + ".jpg", this.onLoadCompleteHandler, LoaderPriority.LevelB);
            }
            return;
        }// end function

        private function onLoadCompleteHandler(param1:ImageInfo) : void
        {
            if (this._icon == null || this.parent == null)
            {
                return;
            }
            this._icon.bitmapData = param1.bitmapData;
            this._icon.width = 24;
            this._icon.height = 24;
            return;
        }// end function

    }
}
